package cn.fintecher.pangolin.entity.elastic;

import cn.fintecher.pangolin.common.enums.ExportTemplateType;
import cn.fintecher.pangolin.common.enums.PublicField;
import cn.fintecher.pangolin.common.utils.Constants;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;

import java.util.Date;
import java.util.List;

/**
 * @Auther: xiaqun
 * @Description: 导入模板实体
 * @Date: 9:52 2019/10/16
 */

@Data
@Document(indexName = Constants.EXPORT_TEMPLATE, type = Constants.EXPORT_TEMPLATE, shards = 1, replicas = 0)
@ApiModel(value = "导入模板实体", description = "导入模板实体")
public class ExportTemplate {
    @Id
    @ApiModelProperty(value = "主键ID")
    private String id;

    @ApiModelProperty(value = "模板名称")
    private String name;

    @ApiModelProperty(value = "模板类型")
    private ExportTemplateType type;

    @ApiModelProperty(value = "委托方ID")
    private String principalId;

    @ApiModelProperty(value = "委托方名称")
    private String principalName;

    @ApiModelProperty(value = "表头起始行")
    private Integer titleStartRow;

    @ApiModelProperty(value = "表头起始列")
    private Integer titleStartCol;

    @ApiModelProperty(value = "数据起始行")
    private Integer dataStartRow;

    @ApiModelProperty(value = "数据起始列")
    private Integer dataStartCol;

    @ApiModelProperty(value = "sheet页数")
    private Integer sheetNumber;

    @ApiModelProperty(value = "模板文件ID")
    private String fileId;

    @ApiModelProperty(value = "公共字段设置")
    private PublicField publicField;

    @ApiModelProperty(value = "配置项")
    private List<ExportTemplateItem> items;

    @ApiModelProperty(value = "创建人")
    private String operator;

    @ApiModelProperty(value = "创建时间")
    private Date operateTime;

    @ApiModelProperty(value = "更新人")
    private String updater;

    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    public void process(String name, Date date, boolean flag) {
        if (flag) {
            this.operator = name;
            this.operateTime = date;
        }
        this.updater = name;
        this.updateTime = date;
    }
}
